package com.grace.cms.general.service.search;

import java.util.List;
import com.grace.cms.common.domain.entity.CmsLink;
import com.grace.cms.common.enums.CommonVisibleEnums;

import com.grace.cms.general.service.IGeneralSearchService;
import com.grace.cms.query.mapper.LinkSearchMapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class GeneralLinkServiceImpl implements IGeneralSearchService {

    @Autowired
    private LinkSearchMapper linkSearchMapper;

    public List<CmsLink> listCmsLinks(CmsLink cmsLink) {
        cmsLink=cmsLink==null?new CmsLink():cmsLink;
        cmsLink.setVisible(CommonVisibleEnums.SHOW.ordinal());
        return linkSearchMapper.listCmsLinks(cmsLink);
    }

    public List<CmsLink> listCmsLinks(Long parentId, String nodeType,Long orderNum) {
        return this.listCmsLinks(getParam(parentId, nodeType, orderNum));
    }

    public CmsLink selectCmsLinkById(long linkId) {
         CmsLink cmsLink = new CmsLink();
         cmsLink.setLinkId(linkId);
         cmsLink.setVisible(CommonVisibleEnums.SHOW.ordinal());
       return cmsLink;
    }



    private CmsLink getParam(Long parentId,String nodeType, Long orderNum){
        CmsLink cmsLink = new CmsLink();
        cmsLink.setOrderNum(orderNum);
        cmsLink.setNodeType(nodeType);
        cmsLink.setParentId(parentId);
        return cmsLink;
    }

}
